<?php
if (!defined('XOOPS_ROOT_PATH')) exit();

require_once XOOPS_MODULE_PATH. '/scuttle/include/TagService.php';

class Scuttle_TagCloudAction extends Scuttle_Action
{
	var $breadcrumbs = null;
	var $pageTitle = null;
	var $moduleHeader = null;
	var $tagCloudArray = array();

	function getDefaultView(&$controller, &$xoopsUser)
	{
		$root =& XCube_Root::getSingleton();

		// gett tag word
		$popularTags =TagService::getAllTags() ;
		// tag cloud font size
		$this->tagCloudArray =  TagService::tagCloud($popularTags, $steps = 20, $sizemin = 120, $sizemax = 300);

		$root =& XCube_Root::getSingleton();
		$this->breadcrumbs[] = array('name' => $root->mContext->mModule->mXoopsModule->getVar('name') , 'url' => XOOPS_MODULE_URL . '/scuttle/' ) ;
		$this->pageTitle = _MD_SC_TAGCLOUD. ' -- '. $root->mContext->mModule->mXoopsModule->getVar('name')  ;
		$this->moduleHeader.= '<link rel="stylesheet" type="text/css" href="' . XOOPS_MODULE_URL. '/scuttle/module.css" />'."\n";

		return SC_FRAME_VIEW_INDEX;
	}

	function executeViewIndex(&$controller, &$xoopsUser, &$render)
	{
		$render->setTemplateName('scuttle_tag_cloud.html');
		$render->setAttribute('xoops_breadcrumbs' ,$this->breadcrumbs) ;
		$render->setAttribute('xoops_pagetitle'  , $this->pageTitle );
		$render->setAttribute('xoops_module_header',$this->moduleHeader);
		$render->setAttribute('tag_cloud' , $this->tagCloudArray);
		$render->setAttribute('rangeOptions', array("0" => _MD_SC_BOOKMARKS_RANGE_0, "2" => _MD_SC_BOOKMARKS_RANGE_1, "1" => _MD_SC_BOOKMARKS_RANGE_2));
		// not used prettyPhoto
		$render->setAttribute('pretty_photo'  , false);
	}

	function execute(&$controller, &$xoopsUser)
	{
		return $this->getDefaultView($controller, $xoopsUser);
	}
}
?>

